$(document).ready(function(){
    // Utility: Generate SEOURL
    $('a#urlAuto').click(function(){
        var name = $('#name').val();
        var url = seoUrl(name);
        $('#seourl').val(url);      
    });
    // Business: Category can't receive itself as father-level category
    var id = $('#id').val();        
    $('#parent option').each(function(){
       if($(this).val() == id){
            $(this).attr('disabled','disabled');
            $(this).css('background-color','#999');
       }       
    });
});
function displayNewscat(id){    
    $("#table-newsCategories tr").each(function(rowIndex) {            
        $(this).find("td").each(function(cellIndex){             
            var data = $(this).find('a').attr('onclick');            
            if(data == 'displayNewscat('+id+')'){                
                $(this).find('a').toggleClass('btn-green');
                $(this).find('a').toggleClass('btn-red');                
                $(this).find('i').toggleClass('fontello-icon-ok-2');                
                $(this).find('i').toggleClass('fontello-icon-cancel-2');
            }                                                                                 
        });
    });     
    $.ajax({
        type: "post",
        url : "admin/newscat/display/",
        data: {
            newsCatId : id,
            act : 'display'
        },
        success: function(data){            
        }        
    });       
}
